package cn.handong.tool.爬虫相关;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://push2.eastmoney.com/api/qt/clist/get?fid=f62&po=1&pz=50&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A13%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A7%2Bf%3A!2%2Cm%3A1%2Bt%3A3%2Bf%3A!2&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13&pn=");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("GET");

		httpConn.setRequestProperty("authority", "push2.eastmoney.com");
		httpConn.setRequestProperty("accept", "*/*");
		httpConn.setRequestProperty("accept-language", "zh-CN,zh;q=0.9");
		httpConn.setRequestProperty("cookie", "qgqp_b_id=2e099ea836a522411afb5ecc1aec123e; cowCookie=true; st_si=02954074293221; cowminicookie=true; st_asi=delete; intellpositionL=1213.35px; HAList=ty-116-01810-%u5C0F%u7C73%u96C6%u56E2-W%2Cty-106-NIO-%u851A%u6765; st_pvi=83724081056603; st_sp=2022-04-18%2022%3A02%3A08; st_inirUrl=http%3A%2F%2Fquote.eastmoney.com%2F; st_sn=35; st_psi=202204191507409-113300301471-7948498164; intellpositionT=1050.2px");
		httpConn.setRequestProperty("referer", "https://data.eastmoney.com/");
		httpConn.setRequestProperty("sec-ch-ua", "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"");
		httpConn.setRequestProperty("sec-ch-ua-mobile", "?0");
		httpConn.setRequestProperty("sec-ch-ua-platform", "\"Windows\"");
		httpConn.setRequestProperty("sec-fetch-dest", "script");
		httpConn.setRequestProperty("sec-fetch-mode", "no-cors");
		httpConn.setRequestProperty("sec-fetch-site", "same-site");
		httpConn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36");

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

